package com.test.vcharts.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;


/**
 * @author wen
 * rest配置
 */

@Configuration
public class RestTemplateConfig {

    @Bean
    public RestTemplate restTemplate(ClientHttpRequestFactory factorys) {
        return new RestTemplate(factorys);
    }

    @Bean
    public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
        SimpleClientHttpRequestFactory factorys = new SimpleClientHttpRequestFactory();
        factorys.setReadTimeout(5000);//单位为ms
        factorys.setConnectTimeout(5000);//单位为ms
        return factorys;
    }


}
